package cn.grayrelese.config;

import cn.grayrelese.rule.GrayMetadataRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class ClientConfig {
    // 声明为Bean，方便应用内使用同一实例
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public IRule GrayMetadataRule()
    {
        return new GrayMetadataRule(); //自定义负载均衡规则
    }
}